/**
 * Project Name:cms
 * File Name:CommentController.java
 * Package Name:com.briup.apps.cms.web.controller.manager
 * Date:2018年9月19日上午11:10:04
 * Copyright (c) 2018, chenzhou1025@126.com All Rights Reserved.
 *
*/

package com.briup.cms.web.controller;


import com.briup.cms.bean.Comment;
import com.briup.cms.service.ICommentService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论相关控制器
 */
@Api(tags="评论管理")
@RestController
@RequestMapping("/auth/comment")
public class CommentController {
	
	@Autowired
	private ICommentService commentService;
	
	@ApiOperation(value = "分页所有评论信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"),
		@ApiImplicitParam(name = "keywords", value = "评论关键字", paramType = "query"),
	})
	@GetMapping("/pageQuery")
	public Message pageQuery(int pageNum, int pageSize, String keywords) {
		PageInfo<Comment> data = commentService.pageQuery(pageNum, pageSize, keywords);
		return MessageUtil.success(data);
	}
	

	@ApiOperation(value="批量删除评论")
	@DeleteMapping(value="/batchDelete")
	public Message batchDelete(int[] ids) {
		commentService.batchDelete(ids);
		return MessageUtil.success("删除成功");
	}
	
	@ApiOperation(value="根据ID删除评论")
	@DeleteMapping(value="/deleteById")
	public Message deleteById(int id) {
		commentService.deleteById(id);
		return MessageUtil.success("删除成功");
	}
	
	@ApiOperation(value="审核评论",notes="status状态：0-待审核，1-不通过，2-通过")
	@PutMapping(value="/check")
	public Message check(int id,int status) {
		commentService.checkComment(id, status);
		return MessageUtil.success("操作成功");
	}

	
}

